package com.lixin.service.impl;

import cn.hutool.jwt.JWTUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lixin.entity.Users;
import com.lixin.mapper.UsersMapper;
import com.lixin.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用于存储用户的基本信息 服务实现类
 * </p>
 *
 * @author lixin
 * @since 2023-07-28
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements IUsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public Users login(Users users) {
        return this.lambdaQuery().eq(Users::getEmail, users.getEmail()).eq(Users::getPassword, users.getPassword()).one();
    }

    @Override
    public Users findById(Integer friendId) {
        return usersMapper.selectById(friendId);
    }

    @Override
    public Users findFriendByUsername(String userName) {
        return this.lambdaQuery().eq(Users::getUsername, userName).one();

    }
}
